//
//  MJRefreshFooter+AutoFixBottomSpace.m
//  MJRefresh
//
//  Created by yons on 24.8.20.
//

#import "MJRefreshFooter+AutoFixBottomSpace.h"

@implementation MJRefreshFooter (AutoFixBottomSpace)

/// 创建footer
/// @param refreshingBlock 回调
+ (instancetype)sm_footerWithRefreshingBlock:(MJRefreshComponentAction)refreshingBlock {
    MJRefreshFooter *cmp = [[self alloc] init];
    cmp.refreshingBlock = refreshingBlock;
    if (@available(iOS 11.0, *)) {
        if ([UIApplication sharedApplication].windows.firstObject.safeAreaInsets.bottom > 0) {
            cmp.ignoredScrollViewContentInsetBottom = 34.0;
        }
    } else {
        cmp.ignoredScrollViewContentInsetBottom = 0;
    }
    return cmp;
}

/// 创建footer
/// @param target target
/// @param action 方法
+ (instancetype)sm_footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action {
    MJRefreshFooter *cmp = [[self alloc] init];
    [cmp setRefreshingTarget:target refreshingAction:action];
    if (@available(iOS 11.0, *)) {
        if ([UIApplication sharedApplication].windows.firstObject.safeAreaInsets.bottom > 0) {
            cmp.ignoredScrollViewContentInsetBottom = 34.0;
        }
    } else {
        cmp.ignoredScrollViewContentInsetBottom = 0;
    }
    return cmp;
}

@end
